<?php
include(getabspath("include/gsp_commercial_details_settings.php"));

function DisplayMasterTableInfo_gsp_commercial_details($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="gsp_commercial_details";

//$strSQL = "SELECT  id,  bcontact_id,  account_id,  ship_mode_id,  ship_from_city,  ship_from_country,  ship_to_country,  ship_to_port,  ship_date,  remarks,  support_documents,  origin_requirements,  book_nos,  ship_status,  status,  signatory,  pre_carriage_mode,  pre_carriage_from,  pre_carriage_to,  ref_id,  \"\" AS buyer_address,  \"\" AS account_address  FROM gsp_commercial_details  ";

$sqlHead="SELECT id,  bcontact_id,  account_id,  ship_mode_id,  ship_from_city,  ship_from_country,  ship_to_country,  ship_to_port,  ship_date,  remarks,  support_documents,  origin_requirements,  book_nos,  ship_status,  status,  signatory,  pre_carriage_mode,  pre_carriage_from,  pre_carriage_to,  ref_id,  \"\" AS buyer_address,  \"\" AS account_address";
$sqlFrom="FROM gsp_commercial_details";
$sqlWhere="";
$sqlTail="";

$where="";
$mKeys = array();
$showKeys = "";

if($detailtable=="gsp_item_details")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
	$showKeys .= " Id: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName=$oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.=" and ".$str;

	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink);
			$xt->assign("id_mastervalue",$value);

//	bcontact_id - 
			$value="";
				$value=DisplayLookupWizard("bcontact_id",$data["bcontact_id"],$data,$keylink,MODE_LIST);
			$xt->assign("bcontact_id_mastervalue",$value);

//	account_id - 
			$value="";
				$value=DisplayLookupWizard("account_id",$data["account_id"],$data,$keylink,MODE_LIST);
			$xt->assign("account_id_mastervalue",$value);

//	ship_mode_id - 
			$value="";
				$value=DisplayLookupWizard("ship_mode_id",$data["ship_mode_id"],$data,$keylink,MODE_LIST);
			$xt->assign("ship_mode_id_mastervalue",$value);

//	ship_from_city - 
			$value="";
				$value=DisplayLookupWizard("ship_from_city",$data["ship_from_city"],$data,$keylink,MODE_LIST);
			$xt->assign("ship_from_city_mastervalue",$value);

//	ship_from_country - 
			$value="";
				$value=DisplayLookupWizard("ship_from_country",$data["ship_from_country"],$data,$keylink,MODE_LIST);
			$xt->assign("ship_from_country_mastervalue",$value);

//	ship_to_country - 
			$value="";
				$value=DisplayLookupWizard("ship_to_country",$data["ship_to_country"],$data,$keylink,MODE_LIST);
			$xt->assign("ship_to_country_mastervalue",$value);

//	ship_to_port - 
			$value="";
				$value=DisplayLookupWizard("ship_to_port",$data["ship_to_port"],$data,$keylink,MODE_LIST);
			$xt->assign("ship_to_port_mastervalue",$value);

//	ship_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"ship_date", "Short Date"),"field=ship%5Fdate".$keylink);
			$xt->assign("ship_date_mastervalue",$value);

//	remarks - 
			$value="";
				$value = ProcessLargeText(GetData($data,"remarks", ""),"field=remarks".$keylink);
			$xt->assign("remarks_mastervalue",$value);

//	support_documents - 
			$value="";
				$value = ProcessLargeText(GetData($data,"support_documents", ""),"field=support%5Fdocuments".$keylink);
			$xt->assign("support_documents_mastervalue",$value);

//	origin_requirements - 
			$value="";
				$value = ProcessLargeText(GetData($data,"origin_requirements", ""),"field=origin%5Frequirements".$keylink);
			$xt->assign("origin_requirements_mastervalue",$value);

//	book_nos - 
			$value="";
				$value = ProcessLargeText(GetData($data,"book_nos", ""),"field=book%5Fnos".$keylink);
			$xt->assign("book_nos_mastervalue",$value);

//	ship_status - 
			$value="";
				$value = ProcessLargeText(GetData($data,"ship_status", ""),"field=ship%5Fstatus".$keylink);
			$xt->assign("ship_status_mastervalue",$value);

//	status - 
			$value="";
				$value = ProcessLargeText(GetData($data,"status", ""),"field=status".$keylink);
			$xt->assign("status_mastervalue",$value);

//	signatory - 
			$value="";
				$value = ProcessLargeText(GetData($data,"signatory", ""),"field=signatory".$keylink);
			$xt->assign("signatory_mastervalue",$value);

//	pre_carriage_mode - 
			$value="";
				$value=DisplayLookupWizard("pre_carriage_mode",$data["pre_carriage_mode"],$data,$keylink,MODE_LIST);
			$xt->assign("pre_carriage_mode_mastervalue",$value);

//	pre_carriage_from - 
			$value="";
				$value=DisplayLookupWizard("pre_carriage_from",$data["pre_carriage_from"],$data,$keylink,MODE_LIST);
			$xt->assign("pre_carriage_from_mastervalue",$value);

//	pre_carriage_to - 
			$value="";
				$value=DisplayLookupWizard("pre_carriage_to",$data["pre_carriage_to"],$data,$keylink,MODE_LIST);
			$xt->assign("pre_carriage_to_mastervalue",$value);

//	ref_id - 
			$value="";
				$value=DisplayLookupWizard("ref_id",$data["ref_id"],$data,$keylink,MODE_LIST);
			$xt->assign("ref_id_mastervalue",$value);

//	buyer_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"buyer_address", ""),"field=buyer%5Faddress".$keylink);
			$xt->assign("buyer_address_mastervalue",$value);

//	account_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"account_address", ""),"field=account%5Faddress".$keylink);
			$xt->assign("account_address_mastervalue",$value);
	$xt->display("gsp_commercial_details_masterlist.htm");
	$strTableName=$oldTableName;
}

?>